import http from '@/libs/http'

/**
 * 添加数据
 * @param data
 */
export function created(data) {
    return http({
        url: '/system/permission/add',
        method: 'post',
        data
    })
}

/**
 * 根据ID删除数据(批量删除)
 * 发送复杂请求（DELETE）时设置withCredentials为true报错
 * @param data：{"idList": ["1","2"]}
 */
export function deleted(data) {
    return http({
        url: '/system/permission/delete',
        method: 'post',
        data
    })
}

/**
 * 修改数据
 * @param data
 */
export function updated(data) {
    return http({
        url: '/system/permission/update',
        method: 'post',
        data
    })
}

/**
 * 根据IdD查询单条数据
 * @param id
 */
export function selectOne(id) {
    return http({
        url: '/system/permission/get/'+id,
        method: 'get'
    })
}

/**
 * 多条件查询数据列表
 * @param query
 */
export function selectList(query) {
    return http({
        url: '/system/permission/list',
        method: 'get',
        params: query
    })
}

/**
 * 多条件查询分页数据
 * @param query
 */
export function selectPage(query) {
    return http({
        url: '/system/permission/page',
        method: 'get',
        params: query
    })
}

/**
 * 根据菜单ID查询权限
 * @param menuId
 */
export function findPermissionByMenuId(menuId) {
    return http({
        url: '/system/permission/findPermissionByMenuId/'+menuId,
        method: 'get'
    })
}

/**
 * 生成菜单默认权限
 * @param data {"menuId": 1, "prefix": "system:permission", "permissions": ["ui,add,delete,update,page"]}
 */
export function generateDefaultPermission(data) {
    return http({
        url: '/system/permission/generateDefaultPermission',
        method: 'post',
        data
    })
}